/*
 * Copyright (c) 2006-2021, RT-Thread Development Team
 *
 * SPDX-License-Identifier: Apache-2.0
 *
 * Change Logs:
 * Date           Author       Notes
 * 2024-02-01     xuxl       the first version
 */
#ifndef APPLICATIONS_BLE_H_
#define APPLICATIONS_BLE_H_ 

#include <stdint.h>
#include <string.h>

#define BLE_RX_DATA_BUF_SIZE                    512
#define BLE_TX_DATA_BUF_SIZE                    512

#define BLE_THREAD_STACK_SIZE                   1024

#define BLE_RST_GPIO_Port               		GPIOB
#define BLE_RST_Pin                     		GPIO_PIN_8

#define BLE_LINK_STATUS_GPIO_Port               GPIOB
#define BLE_LINK_STATUS_Pin                     GPIO_PIN_3

#define BLE_WORK_STATUS_GPIO_Port               GPIOB
#define BLE_WORK_STATUS_Pin                     GPIO_PIN_4

#define BLE_LINK_STATUS_PIN_UNCONNECTED         0
#define BLE_LINK_STATUS_PIN_CONNECTED           1

#define BLE_EVENT_FLAG_RECV_MSG                 (1)
#define BLE_EVENT_FLAG_RST_MODULE               (1 << 1)

extern struct rt_event BleEvent;
extern char BleDevName[64], BleDevNameLen;
extern uint8_t BleRxDataBuf[BLE_RX_DATA_BUF_SIZE];
extern char BleRxDataStrBuf[BLE_RX_DATA_BUF_SIZE * 2 + 1];
extern uint16_t BleRxDataLen;
extern uint8_t BleTxDataBuf[BLE_TX_DATA_BUF_SIZE];
extern char BleTxDataStrBuf[BLE_TX_DATA_BUF_SIZE * 2 + 1];
extern struct rt_thread BleThread;
extern char BleThreadStack[BLE_THREAD_STACK_SIZE];

void BLE_DelayMs(uint16_t Ms);
void BLE_ResetEnable(void);
void BLE_ResetDisable(void);
uint8_t BLE_IsConnected(void);
void BLE_Send(const uint8_t *pDataBuf, uint16_t DataLen);
void BLE_Disconn(void);
void BLE_ModifyDevName(const char *pName);

#endif
